package com.dianrui.moonfire.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.dianrui.moonfire.R;
import com.dianrui.moonfire.bean.CouponModel;

import java.util.List;

public class CouponListAdapter extends BaseQuickAdapter<CouponModel,BaseViewHolder> {

    public CouponListAdapter( @Nullable List<CouponModel> data) {
        super(R.layout.coupon_list_item);
    }

    @Override
    protected void convert(BaseViewHolder helper, CouponModel bean) {
        StringBuilder discountBulider=new StringBuilder();
        discountBulider.append("￥").append(bean.discount);
        helper.setText(R.id.coupon_price, discountBulider.toString());
        helper.setText(R.id.remark, bean.type_name);
        helper.setText(R.id.coupon_name, bean.name);
        helper.setText(R.id.coupon_time, bean.remark);
        //0未选中，1选择中，2静止选中（如满减条件未到达）
        if ("1".equals(bean.is_check)) {
            helper.setChecked(R.id.coupon_cb_balance, true);
        } else if ("0".equals(bean.is_check)) {
            helper.setChecked(R.id.coupon_cb_balance, false);
        } else if ("2".equals(bean.is_check)) {

        }
        helper.addOnClickListener(R.id.click_coupen_layout);
        helper.addOnClickListener(R.id.coupon_cb_balance);
    }
}
